home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-04-08 | 12.2 KB | 301 lines | [TEXT/CCL2] |
- Ruben Kleiman's Mini-Application
-
- Instructions
- ============
-
- Last edit 3/12/92 slm.
-
-
- Introduction.
-
- The Mini-Application is a small application designed as a tutorial
- in Macintosh Common Lisp version 2.0; it is intended to accompany
- the article in D e v e l o p magazine (see the file "About Mini-App").
-
- Full documentation can be found in file "All about the Mini-App";
- it is not necessary to read the develop article.
-
- The Mini-Application is an "application" in the sense that it is a
- complete program that does something specific. A "stand-alone
- application" can be created via MCL's "save-application" function.
-
- This file supersedes files "READ ME FIRST.mw", and
- "READ ME FIRST.word" by Ruben Kleiman 10/25/90, which contained
- the same text, saved in MacWrite and Word format, respectively.
- (Note that a totally different file "Read Me First.lisp" was
- apparently distributed under the name "example.lisp").
-
- As far as possible, Ruben's original text has been preserved. The
- section "How This Example Works" from the file "example.lisp" has
- been merged in ("example.lisp" is superseded - see "About Mini-App").
-
- Please read the following before trying out the Mini-Application.
-
-
- What is the Mini-Application?
-
- The Mini-Application is a program written by Ruben Kleiman intended
- to be a straightforward and clear tutorial of the user interface and
- language capabilities of Macintosh Common Lisp 2.0.
-
- It is organized as a core technology, with a sample application
- that runs on top of it. The core, comprising most of the files in
- the "Program" subfolder, implements all the requisite classes, their
- default behavior and the application's menubar and menus. The
- application, file "mini-app-example.lisp" contains the palette item
- instances and their specialized behavior.
-
- The core, if loaded with a null application, does nothing useful.
- When the application is loaded on top of the core, various types
- of tools and drawing items will appear in the tool palette.
-
- Although not intended as an end-user application, you can build
- windows on which you can draw, manipulate, and script a variety of
- objects (e.g., ovals, rectangles, editable text boxes, pictures,
- icons) using a palette and menus in a direct-manipulation style.
-
- Handlers may be defined for classes of or instances of these
- objects, permitting you to associate code with user interface
- behavior (e.g., mouse clicks associated with mouse-down
- event-handling code on a rectangle).
-
- The application is written to be easily modified and extended
- (many features - e.g., cut/paste, information boxes - are only partly
- implemented to show points of departure where the user may extend
- the code): the aim is to invite the user to gain expertise in
- Macintosh Common Lisp (Version 2.0) and have some fun.
-
-
- Requirements.
-
- You should have the release version of Macintosh Common Lisp 2.0.
-
- MCL2 is available from APDA (see file "Where to buy MCL").
- The Mini-app will not work with earlier versions such as 2.0b1.
- The Mini-app is unlikely to work with later versions without adjustment.
-
- 4MB of application space is recommended, although a minimal MCL
- configuration is sufficient to run the Mini-Application.
-
-
- Installing the Mini-Application.
-
- Make sure the Mini-Application folder is in the same folder
- as the MCL2 application, and is named "Mini-Application".
-
- To load MCL, double-click on the MCL application icon.
-
-
- Running the Mini-Application.
-
- To try out the Mini-Application, simply load it as follows:
-
- Choose Load... in the Eval Menu, and
- load file "build-and-run-mini-app.lisp",
-
- or evaluate the following in the Listener:
-
- (load "ccl:Mini-Application;build-and-run-mini-app.lisp")
-
- Note that CLTL2's host syntax (and hence MCL2's syntax) results
- in the colon and period in the pathname being swapped
- relative to their positions in MCL 2.0b1. If you are not
- familiar with this syntax see the File System chapters in the
- MCL2 Reference and CLTL2.
-
-
- Switching between the Mini-Application and MCL2.
-
- From the Mini-Application to switch back to MCL2's menus:
- - choose Quit in the File menu, or
- - choose Go To Lisp Menubar in the Options menu.
- To switch back to the Mini-Application:
- - choose Go To Mini-Application in the Tools menu.
- - evaluate (show-menus), or if you've made changes
- - evaluate (load "ccl:Mini-Application;build-and-run-mini-app.lisp")
-
- Note that clicking the Quit tool icon in the Mini-Application's Tools
- palette allows you to quit the Mini-Application AND MCL2.
-
-
- Modifying the Mini-Application.
-
- The Mini-Application was designed as a working application to be
- incrementally modified by the reader interested in self-directed
- learning.
-
- File open-all-text-files.lisp has been added. It defines a new
- Fred command meta-a that opens all text files in a specified
- directory. This is very useful for opening all the program files
- at once when browsing.
-
- In addition to the List Definitions menu item mentioned in the
- article, don't forget to use "meta-point" to help you while browsing:
- put the insertion bar in a function, class or global variable name,
- hold down the option key, and type period. This will bring up the
- definition.
-
-
- How the Mini-Application works.
-
- This example of the use of the core functionality of the
- mini-application code supports the creation of a palette containing
- draw-items and tools. A palette carries the tools and draw-items.
- This is just one example of how the Mini-Application core code may
- be built upon.
-
- The user creates a tool palette by selecting the "Palette" menu item
- in the "Options" menu. The user can create any number of windows by
- choosing "New" from the "File" menu and place items from the palette
- on them.
-
-
- The Mini-Application Tool Palette.
-
- The first two items are icons:
- - the Browse-mode tool icon, and
- - the Quit tool icon.
-
- The following items are "draw-items" and are, in descending order:
- - round button
- - radio button
- - check box
- - text field
- - rectangle (QuickDraw)
- - oval (QuickDraw).
-
- Clicking on the Browse-mode tool toggles between Browse mode and
- Authoring modes for ALL "draw-dialog" windows.
- In Browse mode you can manipulate the top window in the usual way,
- but you cannot make changes to its contents. More importantly,
- scripts you attach to draw-items will only run when in Browse mode.
- In Authoring mode you can change the contents of windows, for example
- by dragging draw-items from the palette onto windows (see below).
-
- Note that each mini-application window may, independently of the
- others, be in either authoring or browse mode. Note that each new
- window comes up in Authoring mode, and clicking on the Browse-mode
- tool TOGGLES the mode of all windows.
-
- Clicking on the the Quit icon quits the Mini-Application AND MCL.
-
- You may create any number of windows using the "New" menu item in
- the "File" menu. You can click on any draw-item in the palette
- and drag it out and drop it onto any window. This will create a
- clone of that draw-item on that window. You may drag a draw-item
- within a window or from window to window. You may resize a
- draw-item by grabbing one of its corners or sides (no handles
- show in this implementation: exercise for the reader!) - resizing
- appears in reverse video.
- You can create draw-items of any kind on a window:
- - Select Rectangle Style:
- Click on a palette draw-item to choose that tool.
- Then click and drag out a rectangle in a window where you
- want a draw-item of that type to appear. A draw-item of
- the appropiate size and kind will be created in the window.
- There is an Options menu menu-item for turning this mode on
- or off for the top window.
- - Click and Drag Style:
- Click and drag on a palette draw-item to drag it out, and
- drops it (by releasing the mouse button) on a window.
- The draw-item will be created at the mouse position where
- the drop occurred and the draw-item will be sized to a
- standard size (defaults to its size in the palette - there
- is currently no provision to change the default).
- This method of creating draw-items is always available.
-
- When a draw-item is selected, it's type is shown in the title of
- a new menu, prefixed by "Selected:" If the draw-item is in a
- user-created window, its unique system-generated name of the
- item will be shown after the type.
-
- The Tools palette is not a windoid, which means that if another
- window is active, the Tools palette must be clicked on once to
- activate it, and a second time to choose the tool clicked on.
- For an advanced tutorial on the MCL2 user interface, including
- windoids, study the Interface ToolKit.
-
-
- Creating a stand-alone Mini-Application program.
-
- Even when the Mini-Application has just been loaded, there is no
- guarantee you can simply create a standalone application via:
- (save-application "ccl:Mini-Application pgm"), because
- standalone applications must not contain any pointers or handles
- into the Macintosh heap.
-
- The Mini-Application example program mini-app-example.lisp calls
- function create-tool to create a browse-tool and a quit-tool as it
- loads. Each contains a handle to its icon. create-tool (defined in
- draw-item-class.lisp) calls create-draw-item, which in turn
- originally called get-resource-handle, (defined in utilities.lisp)
- which returns the handle to the icon. This has been changed so
- get-resource-handle is not called until the icon is actually
- displayed by view-draw-contents. Currently, view-draw-contents
- opens the resource file each time; the reader can optimize this
- to speed icon redraw.
-
- Anything that points into the Macintosh heap must be deallocated
- before saving the application, and restored on reload. This really
- means that what is pointed to must be removed from the heap, and
- restored on reload. See *save-exit-functions* and def-load-pointers
- in chapter "Snapshots and Application Versions of MCL" in the Reference.
- File "ccl:examples;binhex;binhex.lisp" shows how to include the icons
- in the saved application's resource fork.
-
- Note: save-application takes a few minutes; don't be too impatient
- and reboot your Mac.
-
-
- Mini-Application Files.
-
- The Mini-Application core consists of the following files:
-
- globals.lisp
- This includes all global definitions.
-
- utilities.lisp
- This includes miscellaneous utility functions required
- by the mini application.
-
- draw-dialog-class.lisp
- This defines the main window classes to be
- used by the mini applications, including all
- the handler functionality. It shows you how
- to handle subviews within the window and
- how to write certain handlers (e.g., mouse
- click events). There is plenty of room here
- for expansion of the mini application's functionality.
-
- menus.lisp
- This includes all menu, menu item and menubar
- definitions for this application. This is a good
- place to start looking. It shows you how to
- create, install and de-install menus and it is
- a good lead-in to the rest of the application.
-
- palette-class.lisp
- This defines some specializations of the
- main window class in order to create palettes.
-
- draw-item-class.lisp
- This defines the functionality of the objects
- which will be drawn within windows (e.g.,
- ovals). It includes dragging, resizing and
- moving code. The classes for all the predefined
- draw-items are here.
-
- default-handlers.lisp
- This includes all the default handlers (i.e., methods)
- for our mini application (e.g., mouse-up, mouse-down).
- You could improve it by adding more default
- functionality (e.g., you might want to add a hilighting
- capability to the button draw-item's mouse-down
- handler).
-
- Individual files are compiled the first time they are loaded, and
- thereafter whenever they are loaded and their source has changed.
-
- end of file Instructions
- -----------------------------------------
-